package com.example.judgepaper.controller;

import com.example.judgepaper.service.StudentStateChangeService;
import com.example.judgepaper.util.Result;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping(value = "/state")
public class StudentStateChangeController {

    private final StudentStateChangeService studentStateChangeService;

    public StudentStateChangeController(StudentStateChangeService studentStateChangeService) {
        this.studentStateChangeService = studentStateChangeService;
    }

    @GetMapping(value = "/stu")
    public Result<Object> updateStudentState(@RequestParam("testId") String testId,
                                      @RequestParam("studentId") String studentId){
        if(studentStateChangeService.studentState(testId,studentId)){
            return new Result<>(200,"更改分值成功",true);
        }else
            return new Result<>(500,"操作异常",false);
    }

    @GetMapping(value = "/cla")
    public Result<Object> updateClassState(@RequestParam("testId") String testId,
                                      @RequestParam("teacherId") String teacherId){
        if(studentStateChangeService.classState(testId,teacherId)){
            return new Result<>(200,"更改分值成功",true);
        }else
            return new Result<>(500,"操作异常",false);
    }

}
